package com.lzp.utils.error;

/**
 * 通用异常架构
 */
public abstract class BaseRuntimeException extends RuntimeException implements CommonError {

    // 组合，强关联
    private CommonError commonError;

    public BaseRuntimeException(CommonError commonError) {
        super();
        this.commonError = commonError;
    }

    public BaseRuntimeException(CommonError commonError, String customErrMsg) {
        super();
        this.commonError = commonError;
        this.commonError.setErrorMsg(customErrMsg);
    }

    @Override
    public int getCode() {
        return this.commonError.getCode();
    }

    @Override
    public String getMessage() {
        return this.commonError.getMessage();
    }

    @Override
    public CommonError setErrorMsg(String errorMsg) {
        this.commonError.setErrorMsg(errorMsg);
        return this;
    }
}